#define xuser mixc::powerful_cat
#include"lang/cxx/count_of.hpp"
#include"lang/cxx/ignore_case.hpp"
#include"lang/cxx.hpp"
#include"math/random.hpp"
#include"mixc.hpp"
#include"utils/array.hpp"

xinit(xuser::the_main){
    using namespace xuser;

    // 寻找星星的个数
    {
        auto && origin          = array<char, 8>{};
        auto    star            = '*';

        origin.foreach([&](char & item){
            if (auto is_star = random<bool>(); is_star){
                item            = star;
            }
            else{
                item            = 'A' + random<uxx>() % 26;
            }
        });

        auto    line            = c08{ (char *)origin, origin->length };

        xhint(line, line.count_of(star));
    }

    // 寻找 'a' 或者 'A'
    {
        auto && origin          = array<char, 8>{};

        origin.foreach([&](char & item){
            if (auto is_a = random<bool>(); is_a){
                item            = random<bool>() ? 'A' : 'a';
            }
            else{
                item            = 'A' + random<uxx>() % 26;
            }
        });

        auto    line            = c08{ (char *)origin, origin->length };

        // 通过 ignore_case<char> 忽略大小写
        xhint(line, line.count_of('A', ignore_case<char>));
    }

    // 寻找特殊代码出现的次数
    {
        xhint(c08{"A-T,G-C,A-U,G-C,A-T,G-C"}.count_of("A-T,G-C"));
        xhint(c08{"a-T,G-c,A-U,g-c,a-T,g-C"}.count_of("A-T,G-C"));
        xhint(c08{"a-T,G-c,A-U,g-c,a-T,g-C"}.count_of("A-T,G-C", ignore_case<char>));
    }
};
